#pragma once

#define DIRECTINPUT_VERSION 0x0800
/// http://www.toymaker.info/Games/html/directinput.html

#include "DX11Includes.h"

#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")

#define DIMOUSE_LEFTBUTTON   0
#define DIMOUSE_RIGHTBUTTON  1
#define DIMOUSE_MIDDLEBUTTON 2
#define DIMOUSE_4BUTTON      3
#define DIMOUSE_5BUTTON      4
#define DIMOUSE_6BUTTON      5
#define DIMOUSE_7BUTTON      6
#define DIMOUSE_8BUTTON      7


class InputManager
{
public:
	InputManager(void);
	~InputManager(void);

	bool Initialize(HINSTANCE, HWND, int, int);
	void Shutdown();
	bool UpdateInputManager();

	bool isKeyPressed(unsigned char key);
	bool isKeyRelease(unsigned char key);
	bool isKeyPressing(unsigned char key);
	bool isKeyReleasing(unsigned char key);

	bool isMouseButtonPressed(unsigned char mb);
	bool isMouseButtonRelease(unsigned char mb);
	bool isMouseButtonPressing(unsigned char mb);
	bool isMouseButtonReleasing(unsigned char mb);

	void GetMouseLocation(int&, int&);
	void GetRelativeMouseLocation(int&, int&);

	void ShowMouseCursor(bool show) { ShowCursor(show); }
	void SetMouseCursorPosition(int x, int y) { SetCursorPos(x,y); }


private:
	bool ReadKeyboard();
	bool ReadMouse();
	void ProcessInput();

	IDirectInput8* m_directInput;
	IDirectInputDevice8* m_keyboard;
	IDirectInputDevice8* m_mouse;
	
	unsigned char m_keyboardState[256];
	unsigned char m_LastkeyboardState[256];
	DIMOUSESTATE m_mouseState;
	DIMOUSESTATE m_LastmouseState;

	int m_screenWidth, m_screenHeight;
	int m_mouseX, m_mouseY;
	int r_mouseX, r_mouseY;

};


